﻿
// **************************************************************************
//    Class Created by Mick Doherty (Dotnetrix) Feb 2010
//    http://dotnetrix.co.uk/
//
//    ...for GlassUI (an AeroGlass UI Library)
//    http://glassui.codeplex.com/
// **************************************************************************

using System;
using System.Drawing;
using System.Runtime.InteropServices;
using System.Windows.Forms;
using System.Text;

namespace GlassUI
{
    internal sealed partial class NativeMethods
    {
        internal sealed class UXTHEME
        {
            private UXTHEME() { }

            #region Method Imports

            [DllImport("uxtheme.dll", CharSet = CharSet.Unicode, SetLastError = true)]
            public static extern IntPtr DrawThemeTextEx(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, string pszText, int iCharCount, TextFormatFlags dwFlags, ref USER32.RECT pRect, ref DTTOPTS pOptions);

            //[DllImport("uxtheme.dll", EntryPoint = "DrawThemeTextEx", CharSet = CharSet.Unicode, SetLastError = true)]
            //public static extern IntPtr MeasureThemeTextEx(IntPtr hTheme, IntPtr hdc, int iPartId, int iStateId, string pszText, int iCharCount, TextFormatFlags dwFlags, out USER32.RECT pRect, DTTOPTS pOptions);

            [DllImport("uxtheme.dll", CharSet = CharSet.Unicode, SetLastError = true)]
            public extern static int GetThemeTextExtent(IntPtr hTheme, IntPtr hDC,  int iPartId, int iStateId, string pszText, int iCharCount, int dwTextFlags, ref NativeMethods.USER32.RECT pBoundingRect, out NativeMethods.USER32.RECT pExtentRect);

            #endregion

            #region Structures

            [StructLayout(LayoutKind.Sequential)]
            public struct DTTOPTS
            {
                public int dwSize;
                public DrawThemeTextFlags dwFlags;
                public int crText;
                public int crBorder;
                public int crShadow;
                public TextShadowType iTextShadowType;
                public Point ptShadowOffset;
                public int iBorderSize;
                public int iFontPropId;
                public int iColorPropId;
                public int iStateId;
                public bool fApplyOverlay;
                public int iGlowSize;
                public IntPtr pfnDrawTextCallback;
                public IntPtr lParam;
            }

            #endregion

            #region Enumerations

            [Flags()]
            public enum DrawThemeTextFlags
            {
                DTT_TEXTCOLOR = 0x1,
                DTT_BORDERCOLOR = 0x2,
                DTT_SHADOWCOLOR = 0x4,
                DTT_SHADOWTYPE = 0x8,
                DTT_SHADOWOFFSET = 0x10,
                DTT_BORDERSIZE = 0x20,
                DTT_FONTPROP = 0x40,
                DTT_COLORPROP = 0x80,
                DTT_STATEID = 0x100,
                DTT_CALCRECT = 0x200,
                DTT_APPLYOVERLAY = 0x400,
                DTT_GLOWSIZE = 0x800,
                DTT_CALLBACK = 0x1000,
                DTT_COMPOSITED = 0x2000,
                DTT_VALIDBITS = DTT_TEXTCOLOR |
                                      DTT_BORDERCOLOR |
                                      DTT_SHADOWCOLOR |
                                      DTT_SHADOWTYPE |
                                      DTT_SHADOWOFFSET |
                                      DTT_BORDERSIZE |
                                      DTT_FONTPROP |
                                      DTT_COLORPROP |
                                      DTT_STATEID |
                                      DTT_CALCRECT |
                                      DTT_APPLYOVERLAY |
                                      DTT_GLOWSIZE |
                                      DTT_COMPOSITED
            }

            public enum TextShadowType
            {
                None,
                Single,
                Continuos
            }

            #endregion
        }
    }
}
